package com.firewolf.springboot.controler;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.firewolf.springboot.beans.Student;
import com.firewolf.springboot.service.impl.StudentServiceImpl;

@RestController
public class StudentController {
	
	@Autowired
	private StudentServiceImpl sService;
	
	@RequestMapping("/save")
	public String addData(){
		List<Student> sList = new ArrayList<>();
		sList.add(new Student("刘兴",20,"男"));
		sList.add(new Student("lisi",40,"nan"));
		sList.add(new Student("wangwu",30,"nv"));
		sService.batchSave(sList);
		return "添加数据成功！！！";
	}
	
	
	@RequestMapping("/find/{id}")
	public Student findStu(@PathVariable("id") Long id){
		return sService.findById(id);
	}
	
	@RequestMapping("/remove/{id}")
	public String removeCache(@PathVariable("id") Long id){
		sService.deleteFromCache(id);
		return "remove success ！！！";
	}
	
	@RequestMapping("/test")
	public String test(){
		return sService.redisTest();
	}
	
}
